<?php

namespace sil29\VitrineBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Security\Core\SecurityContext;

class SecurityController extends Controller {
	public function loginAction() {
		$request = $this->getRequest ();
		$session = $request->getSession ();
		if ($request->attributes->has ( SecurityContext::AUTHENTICATION_ERROR )) {
			$error = $request->attributes->get ( SecurityContext::AUTHENTICATION_ERROR );
					return $this->render ( 'sil29VitrineBundle:Security:login.html.twig', array (
				'last_username' => $session->get ( SecurityContext::LAST_USERNAME ),
				'error' => $error 
		) );
		} else 

		{
			
			$error = $session->get ( SecurityContext::AUTHENTICATION_ERROR );
			$this->getUser();
			$session->remove ( SecurityContext::AUTHENTICATION_ERROR );
			return $this->render ( 'sil29VitrineBundle:Security:login.html.twig', array (
					'last_username' => $session->get ( SecurityContext::LAST_USERNAME ),
					'error' => $error	) );
		}

	}
}
